package cn.practice.controller;// cn/practice/controller/StudentController.java

import cn.practice.service.StudentService;
import cn.practice.service.result.ImportResult;
import cn.practice.service.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/api/student")
public class StudentController {

    @Autowired
    private StudentService studentService;

    @PostMapping("/import")
    public ResponseEntity<?> importStudents(@RequestParam("file") MultipartFile file) {
        Result<ImportResult> importResultResult = studentService.importStudents(file);
        ResponseEntity<Result<ImportResult>> result = ResponseEntity.ok(importResultResult);
        return result;
    }
}